import { Component, OnInit } from '@angular/core'
import { ApiService } from '../../services/api.service'
import { ModalConfirmComponent } from '@app/shared/components/modal-confirm/modal-confirm.component'
import { plainToClass } from 'class-transformer'
import { DictService } from '@app/shared/utils/dict.service'
import { QlMessageService } from 'qloud-angular'
import { ModalService } from '@app/shared/utils'
import { NetService, PageService } from '@app/core/http'
import { Router } from '@angular/router'
import { FormBuilder, Validators, FormGroup } from '@angular/forms'

@Component({
  selector: 'app-activity-list',
  templateUrl: './activity-list.component.html',
  styleUrls: ['./activity-list.component.scss'],
  providers: [ModalService, PageService]
})
export class ActivityListComponent implements OnInit {
  public activityList: any[] = []
  constructor(
    private apiService: ApiService,
    private fb: FormBuilder,
    public modal: ModalService,
    public pageService: PageService,
    private message: QlMessageService,
    private router: Router
  ) {}

  ngOnInit() {
    this.getActivityList()
  }

  getActivityList() {
    this.apiService.getActivityList().subscribe(data => {
      this.activityList = data
    })
  }

  public delFun() {
    this.modal
      .open({
        title: '确认删除',
        component: ModalConfirmComponent
      })
      .subscribe(() => {
        this.apiService.delactivity().subscribe(data => {
          this.message.success(data[0].message)
        })
      })
  }
}
